package main

import (
	"earth/config"
	"earth/middleware"
	"earth/models"
	"earth/routes"
	"earth/utils"

	"github.com/gin-gonic/gin"
)

func main() {
	utils.LoadEnvVars()
	config, _ := config.Init()

	models.Init(config.DB)

	gin.SetMode(gin.DebugMode)

	app := gin.New()

	app.Use(gin.Logger())
	app.Use(gin.Recovery())
	app.Use(middleware.RequestID(middleware.RequestIDOptions{AllowSetting: false}))
	// r.Use(middleware.Auth())
	app.Use(middleware.CORS(middleware.CORSOptions{}))

	routes.Register(app)

	port := utils.GetEnv("PORT", "8080")

	app.Run(":" + port) // listen and serve
}
